package com.share.homestay.hystrix;

import com.share.homestay.entity.OrderLogs;
import com.share.homestay.entity.SysUser;
import com.share.homestay.entity.TjPermissions;
import com.share.homestay.pojo.JsonResult;
import com.share.homestay.service.SysUserServiceFeign;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class SysUserServiceHystrix implements FallbackFactory<SysUserServiceFeign> {
    @Override
    public SysUserServiceFeign create(Throwable cause) {
        return new SysUserServiceFeign(){

            @Override
            public JsonResult sysUserPageQuery(SysUser sysUser, Integer pageNum, Integer pageSize) {
                throw new RuntimeException("运行用户分页条查时出现异常");
            }

            @Override
            public SysUser getUserByUsername(String username) {
                return null;
            }

            @Override
            public List<TjPermissions> selectPermsByUserId(Long userId) {
                throw new RuntimeException("运行查找用户的角色");

            }

            @Override
            public void addOrderLogs(OrderLogs orderLogs) {
                throw new RuntimeException("调用新增日志方法时出现异常");
            }

            @Override
            public JsonResult selectLogs(OrderLogs orderLogs, Integer pageNum, Integer pageSize) {
                throw new RuntimeException("运行条查日志信息时出现异常");
            }

            @Override
            public List<SysUser> findAllUser() {
                throw new RuntimeException("运行查询全部用户时出现异常");
            }


        };
    }
}
